package user.zc.excel.data.builder;


import user.zc.helper.ExcelAssistant;
import user.zc.excel.data.info.ICell;
import user.zc.excel.data.style.IStyle;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class DataStyleBuilder<T> implements IBuilder<T, Map<Field, IStyle.StyleInfo>>{
    @Override
    public Map<Field, IStyle.StyleInfo> collect(Class<T> clazz) {
        List<Field> fields = fields(clazz);
        Map<Field,IStyle.StyleInfo> map = new HashMap<>();
        for (Field field : fields) {
            map.put(field, ICell.CellType.instanceByClass(field.getType()).parse(field.getAnnotation(ExcelAssistant.class).cell()));
        }
        return map;
    }
}
